<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="javax.servlet.jsp.JspWriter"%>
<%@page import="org.emergency.framework.model.contactTree.TbPermissionTreeNode"%>
<%@page import="org.emergency.framework.model.contactTree.TbPermissionTree"%>
<%@page import="org.emergency.framework.common.Context"%>
<%@page import="org.emergency.framework.service.common.ITbPermissionTreeService"%>
<%--

这是角色权限配置
--%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<base href="<%=basePath%>">
<head>
	<link rel="stylesheet" type="text/css" href="css/user.css">
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>

<%--
tree plug-in
--%>
<script src="js/jquery.checktree.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
	$("ul.tree").checkTree({
		/*
		// You can add callbacks to the expand, collapse, check, uncheck, and  halfcheck
		// events of the tree. The element you use as the argument is the LI element of
		// the object that fired the event.
		onExpand: function(el) {
			console.log("expanded ", el.find("label:first").text());
		},
		onCollapse: function(el) {
			console.log("collapsed ", el.find("label:first").text());
		},
		onCheck: function(el) {
			console.log("checked ", el.find("label:first").text());
		},
		onUnCheck: function(el) {
			console.log("un checked ", el.find("label:first").text());
		},
		onHalfCheck: function(el) {
			console.log("half checked ", el.find("label:first").text());
		}*/
		/*
		// You can set the labelAction variable to either "check" or "expand" 
		// to change what happens when you click on the label item.
		// The default is expand, which expands the tree. Check will toggle
		// the checked state of the items.
		labelAction: "expand"
		*/
		/*
		// You can also change what happens when you hover over a label (over and out)
		onLabelHoverOver: function(el) { alert("You hovered over " + el.text()); },
		onLabelHoverOut: function(el) { alert("You hovered out of " + el.text()); }
		*/
	});
});
</script>

<link type="text/css" rel="stylesheet" href="css/checktree.css" />
<%--
costom
--%>
<script src="oa/permission/js/permissionTree.js" type="text/javascript"></script>


</head>
<body>
<div>角色权限配置</br>
当前角色：<div id='roleId'>
<% out.print(request.getParameter("theroleId"));%>
</div></div>
<img alt="" src="img/column.gif" style='width:100%;height:5px'>
<div style = 'margin-left: 200px'>
		<%!public void printLocalTree(TbPermissionTreeNode node, ServletRequest request,
			ServletResponse response, JspWriter out) throws Exception {
			out.println("<lable>");
				out.println(node.getName());
				out.println(node.getNodeId()+"");
				
			out.println("</lable>");
			out.println("<ul class='tree' style='margin-left: 15px; '>");
		List<TbPermissionTreeNode> nodeList = node.getChildren();
		for (int i = 0; i < nodeList.size(); i++) {
			out.println("<li id = "+nodeList.get(i).getNodeId()+" >");
			out.println("<input type='checkbox' name='geo' class='checkbox' />");
			printLocalTree(nodeList.get(i), request, response, out);
			out.println("</li>");
		}
		out.println("</ul>");
	}%>
		<%
		TbPermissionTree permissionTree = ((ITbPermissionTreeService) Context.webApplicationContext
					.getBean("tbPermissionTreeServiceImpl")).getTbRoleTreeTree();

		TbPermissionTreeNode node = permissionTree.getRootNode();
			printLocalTree(node, request, response, out);
		%>
</div>
<img alt="" src="img/column.gif" style='width:100%;height:5px'>
</br>

<div style='text-align: center;'>
<input type='button' value='提交' class = 'submit'/>
<input type='button' value='返回' id = 'return'/>
</div>
</body>
</html>
